﻿using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using VisualWip.TFS2010Common;
using WorkItem = VisualWip.Core.WorkItem;

namespace VisualWip.TFS2010Providers
{
    public class WorkItemListQuery : WorkItemQueryBase
    {
        public WorkItemListQuery(TfsConnection connection) : base(connection)
        {
        }

        protected override Collection<WorkItem> RunGetWork()
        {
            var workItemCollection = Connection.WorkItemStore.Query(QueryText,
                                                                              Connection.QueryContext);
            return
                WorkItemTransformer.Transform(Connection,workItemCollection,DownloadDisplayFieldsOnly);
        }

        protected override int RunGetWorkCount()
        {
            var query = new Query(Connection.WorkItemStore, QueryText, Connection.QueryContext);
            return query.RunCountQuery();
        }
    }
}